package com.ppc.ugo.service.impl;

import com.ppc.ugo.dao.mapper.CatItemMapper;
import com.ppc.ugo.dao.pojo.CatItem;
import com.ppc.ugo.service.CatItemService;
import com.ppc.ugo.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
@Slf4j
public class CatItemServiceImpl implements CatItemService {
    @Resource
    private CatItemMapper catItemMapper;

    @Override
    public Result getCatItems() {
        List<CatItem> catItems = catItemMapper.selectList(null);

        return Result.success(catItems);
    }

    @Override
    public void addItem(CatItem catItem) {
        catItemMapper.insert(catItem);
        log.info("新增分类：{}", catItem.getName());
    }
}
